import React, { useCallback } from 'react';


const FancyButton = React.forwardRef((props, ref) => (
  <button ref={ref} onClick={props.onClick} className="FancyButton">
    {props.children}
  </button>
));

// You can now get a ref directly to the DOM button:

export default () => {
  const ref = React.createRef();
  const buttonClick = useCallback(()=>{
    alert(ref.current.className);
  });
  return (
    <div>
      <FancyButton ref={ref} onClick={buttonClick} >Click me!</FancyButton>
    </div>
  );
}